﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data;


public partial class AdminPages_RegisterReturnDispatch : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void GridView_Return_RowCommand(object sender, GridViewCommandEventArgs e)
    {

        TableCell MovieID = GridView_Return.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0];
        TableCell Username=GridView_Return.Rows[Convert.ToInt32(e.CommandArgument)].Cells[4];
        TableCell StockID = GridView_Return.Rows[Convert.ToInt32(e.CommandArgument)].Cells[5];


        MembershipUser user = Membership.GetUser(Convert.ToString(Username.Text));

        //
        DVDTableAdapters.DVDStockTableAdapter ta1 = new DVDTableAdapters.DVDStockTableAdapter();
        ta1.UpdateMovieAvailability(true, Convert.ToInt32(StockID.Text));

        DVDTableAdapters.ActualRentTableAdapter ta4 = new DVDTableAdapters.ActualRentTableAdapter();
        ta4.DeleteActualRentedMovie(Convert.ToInt32(MovieID.Text),(Guid)user.ProviderUserKey);

        //update dvdhistory


        //Set USer DVD rented dvd=false
        DVDTableAdapters.CustomerTableAdapter ta3 = new DVDTableAdapters.CustomerTableAdapter();
        ta3.UpdateDVDDispatchAndReturn(false, (Guid)user.ProviderUserKey);

        user=null;

        Response.Redirect(Request.RawUrl);

    }
}